package com.mygame.client.handler;


import com.mygame.client.service.GameClientConfig;
import com.mygame.client.service.handler.GameClientChannelContext;
import com.mygame.client.service.logichandler.SystemMessageHandler;
import com.mygame.common.component.BaseRoute;
import com.mygame.common.component.RequestPacket;
import com.mygame.common.component.annotation.Handler;
import com.mygame.common.component.annotation.Route;
import com.mygame.common.msg.CommandEnum;
import com.mygame.common.msg.ServiceEnum;
import com.mygame.common.protobuf.gameMsg.BuyArenaChallengeTimesResponse;
import com.mygame.common.protobuf.gameMsg.EnterGameResponse;
import com.mygame.common.protobuf.gameMsg.IMSendResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Route(serviceType = ServiceEnum.CLIENT)
public class SystemHandler implements BaseRoute<RequestPacket> {

    @Autowired
    private GameClientConfig gameClientConfig;
    private static Logger logger = LoggerFactory.getLogger(SystemMessageHandler.class);

    @Override
    public void onReceive(RequestPacket packet) {
        System.out.println("CommonHandler");
    }



    @Handler(cmd = CommandEnum.S2C_ENTER_GAME)
    public void enterGameResponse(EnterGameResponse response, GameClientChannelContext ctx) {
        logger.debug("进入游戏成功：{}",response.getNickname());
    }
    @Handler(cmd = CommandEnum.S2C_BUY_ARENA_CHALLENGE_TIMES_RSP)
    public void buyArenaChallengeTimes(BuyArenaChallengeTimesResponse response, GameClientChannelContext ctx) {
        logger.debug("购买竞技场挑战次数成功");
    }
    @Handler(cmd = CommandEnum.S2C_IM_SEND)
    public void chatMsg(IMSendResponse response, GameClientChannelContext ctx) {
        logger.info("聊天信息-{}说：{}",response.getSender(),response.getChat());
    }

    @Handler(cmd = CommandEnum.S2C_SEND_IM_MSG)
    public void chatMsgIM(IMSendResponse response,GameClientChannelContext ctx) {
        logger.info("聊天信息-{}说：{}",response.getSender(),response.getChat());
    }

}